package topcoder.srm586;

import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Set;

public class TeamsSelection {
	public String simulate(int[] pref1, int[] pref2) {

		int boys[] = new int[pref1.length + 1];
		Arrays.fill(boys, -1);

		Set<Integer> s1 = new LinkedHashSet<Integer>();
		Set<Integer> s2 = new LinkedHashSet<Integer>();
		for (int i = 0; i < pref1.length; i++) {
			s1.add(pref1[i]);
			s2.add(pref2[i]);
		}

		int turn = 1;
		while (s1.isEmpty() == false || s2.isEmpty() == false) {

			for (int s : s1) {
				if (turn == 1 && boys[s] == -1) {
					turn = 2;
					boys[s] = 1;
					s2.remove(s);
					s1.remove(s);
					break;
				}

			}

			for (int s : s2) {
				if (turn == 2 && boys[s] == -1) {
					turn = 1;
					boys[s] = 2;
					s2.remove(s);
					s1.remove(s);
					break;
				}
			}

		}

		StringBuilder res = new StringBuilder();
		for (int i = 1; i < boys.length; i++) {
			res.append(boys[i]);
		}
		return res.toString();
	}

	public static void main(String[] args) {
		TeamsSelection ts = new TeamsSelection();

		int[] preference1 = { 8, 7, 1, 2, 4, 5, 6, 3, 9 };
		int[] preference2 = { 7, 2, 4, 8, 1, 5, 9, 6, 3 };
		System.out.println(ts.simulate(preference1, preference2));

	}

}
